package partition;

import bean.Employee;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * partition.EmployeePartition
 * 分区
 * @author zhangyimin
 * @version 1.0
 * @date 2018-07-31 下午3:31
 */
public class EmployeePartition extends Partitioner<IntWritable, Employee> {

    /**
     *
     * @param intWritable
     * @param employee
     * @param numPartition  建立多少个分区
     * @return
     */
    @Override
    public int getPartition(IntWritable intWritable, Employee employee, int numPartition) {
        if (employee.getDeptNo()==10){
            return  1%numPartition;
        }else if (employee.getDeptNo()==20){
            return  2%numPartition;
        }else {
            return  3%numPartition;
        }
    }
}
